var Fight,
  __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function s() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((s.prototype = i.prototype), new s()));
      };
    })(),
  Sprite = Laya.Sprite;
!(function (t) {
  var e = (function (e) {
    function i() {
      var i = e.call(this) || this;
      return (
        (i.isInit = !1),
        (i.isLoad = !1),
        (i.lastAction = null),
        (i.isNewImage = !1),
        (i.width = 54),
        (i.height = 64),
        (i.state = 0),
        (i.shuang = new Laya.Animation()),
        (i.shuang.interval = 100),
        (i.shuang.scaleX = 0.5),
        (i.shuang.scaleY = 0.5),
        i.addChild(i.shuang),
        (i.body = new Laya.Animation()),
        (i.body.interval = 100),
        i.addChild(i.body),
        (i.body.scaleX = 0.5),
        (i.body.scaleY = 0.5),
        (i.hp = new t.Strip(1)),
        (i.mp = new t.Strip(1, 0, "#3366ff")),
        i.addChild(i.hp),
        i.addChild(i.mp),
        (i.hp.alpha = 0),
        (i.mp.alpha = 0),
        i.hp.draw(),
        i.mp.draw(),
        (i.buff = new t.FightBuff()),
        i.addChild(i.buff),
        i.buff.pos(30, 10),
        (i.heartImg = new Laya.Image()),
        (i.heartImg.width = 72),
        (i.heartImg.height = 72),
        i.addChild(i.heartImg),
        i.heartImg.pos(0, -8),
        (i.speedImg = new Laya.Image("comp/commonpic/speed_arrows.png")),
        (i.speedImg.width = 15),
        (i.speedImg.height = 25.5),
        i.addChild(i.speedImg),
        i.speedImg.pos(46, -8),
        (i.speedLabel = new Laya.Label("1")),
        (i.speedLabel.color = "#FFFFFF"),
        (i.speedLabel.fontSize = 10),
        i.addChild(i.speedLabel),
        i.speedLabel.pos(51, -2),
        (i.typeImg = new Laya.Image()),
        (i.typeImg.width = 14),
        (i.typeImg.height = 14),
        i.addChild(i.typeImg),
        i.typeImg.pos(0, -7),
        i
      );
    }
    return (
      __extends(i, e),
      (i.prototype.init = function (t, e, s, a, h, o) {
        if ((void 0 === h && (h = 1), void 0 === o && (o = 1), !this.isLoad))
          return (
            (this.heroName = t),
            (this.oldName = t),
            (this.isNewImage = this.isNewImageSet()),
            (this.side = e),
            this.speedLabel.changeText(this.mapSpeed(a)),
            (this.typeImg.skin = i.typeImgArray[s]),
            h > 1 && (h = 1),
            o > 1 && (o = 1),
            (this.hpNum = h),
            (this.mpNum = o),
            (this.atlas = i.path + t + ".atlas"),
            void Laya.loader.load(
              this.atlas,
              Laya.Handler.create(this, this.onLoad),
              null,
              Laya.Loader.ATLAS
            )
          );
        this.hpNum > 0 &&
          (this.hp.visible || (this.hp.visible = !0),
          this.mp.visible || (this.mp.visible = !0),
          this.speedLabel.visible || (this.speedLabel.visible = !0),
          this.speedImg.visible || (this.speedImg.visible = !0),
          this.typeImg.visible || (this.typeImg.visible = !0)),
          (this.heartImg.visible = !1),
          (this.hp.scaleX = this.t_scaleX),
          (this.mp.scaleX = this.t_scaleX),
          (this.speedLabel.scaleX = this.t_scaleX),
          (this.speedImg.scaleX = this.t_scaleX),
          (this.heartImg.scaleX = this.t_scaleX),
          (this.typeImg.scaleX = this.t_scaleX),
          -1 == this.t_scaleX
            ? (this.speedImg.pos(14, -8),
              this.heartImg.pos(70, -8),
              this.speedLabel.pos(9, -2),
              this.typeImg.pos(60, -7))
            : (this.speedImg.pos(46, -8),
              this.heartImg.pos(0, -8),
              this.speedLabel.pos(51, -2),
              this.typeImg.pos(0, -7)),
          this.posOffset(),
          this.pos(this.t_x, this.t_y),
          (this.scaleX = this.t_scaleX),
          this.buff.visible || (this.buff.visible = !0),
          (this.buff.scaleX = this.t_scaleX),
          this.refresh(this.hpNum, this.mpNum),
          (this.isInit = !0),
          null != this.lastAction && this.onceAction(this.lastAction),
          this.parent.event("RoleInit", this.id);
      }),
      (i.prototype.onLoad = function (t) {
        if (i.isCache[this.heroName])
          return (this.isLoad = !0), void this.init(null, null, null, null);
        var e = 1;
        this.isNewImage && (e = 2),
          Laya.Animation.createFrames(
            this.aniUrls("attack", e),
            this.heroName + "_attack"
          ),
          Laya.Animation.createFrames(
            this.aniUrls("idle", 4),
            this.heroName + "_idle"
          ),
          console.log("this.heroName ======================= " + this.heroName),
          (i.isCache[this.heroName] = !0),
          (this.isLoad = !0),
          this.init(null, null, null, null);
      }),
      (i.prototype.payAction = function (t) {
        this.body.play(0, !0, this.heroName + "_" + t);
        this.getBounds();
        this.hp.pos(30, -4), this.mp.pos(30, 0);
      }),
      (i.prototype.aniUrls = function (t, e) {
        for (var i = [], s = 1; s <= e; s++)
          i.push("fight/hero/" + this.heroName + "/" + t + s + ".png");
        return i;
      }),
      (i.prototype.aniUrls1 = function (t, e) {
        var i = [];
        return i.push("fight/hero/" + this.heroName + "/" + t + "3.png"), i;
      }),
      (i.prototype.hideStatus = function () {
        (this.hp.alpha = 0),
          (this.mp.alpha = 0),
          (this.buff.alpha = 0),
          (this.speedImg.alpha = 0),
          (this.speedLabel.alpha = 0),
          (this.typeImg.alpha = 0);
      }),
      (i.prototype.showStatus = function () {
        (this.hp.alpha = 1),
          (this.mp.alpha = 1),
          (this.buff.alpha = 1),
          (this.speedImg.alpha = 1),
          (this.speedLabel.alpha = 1),
          (this.typeImg.alpha = 1);
      }),
      (i.prototype.refresh = function (t, e) {
        t > 1 && (t = 1),
          e > 1 && (e = 1),
          this.hp.refresh(t),
          this.mp.refresh(e);
      }),
      (i.prototype.refreshBuff = function () {
        this.buff.refresh(this.state);
      }),
      (i.prototype.setState = function (t) {
        this.state = t;
      }),
      (i.prototype.addBuff = function (t) {
        this.state = this.state | t;
      }),
      (i.prototype.removeBuff = function (t) {
        this.state = this.state & ~t;
      }),
      (i.prototype.addHeartVal = function (t, e) {
        var i = "comp/commonpic/" + t + ".png";
        (this.heartImg.skin = i),
          (this.heartImg.visible = !0),
          Laya.timer.once(1200 / e, this, function () {
            this.heartImg.visible = !1;
          });
      }),
      (i.prototype.getState = function () {
        return this.state;
      }),
      (i.prototype.setSpeed = function (t) {
        this.speedLabel.changeText(this.mapSpeed(t));
      }),
      (i.prototype.change = function (t, e, i) {
        void 0 === e && (e = 1),
          void 0 === i && (i = 1),
          this.speedLabel.changeText(this.mapSpeed(t)),
          e > 1 && (e = 1),
          i > 1 && (i = 1),
          (this.hpNum = e),
          (this.mpNum = i);
      }),
      (i.prototype.onceAction = function (t) {
        this.isInit
          ? (this.showStatus(), this.payAction(t))
          : (this.lastAction = t);
      }),
      (i.prototype.setId = function (t) {
        this.id = t;
      }),
      (i.prototype.getId = function () {
        return this.id;
      }),
      (i.prototype.thePos = function (t, e, i) {
        (this.t_x = t), (this.t_y = e), (this.t_scaleX = i);
      }),
      (i.prototype.setPos = function (t, e) {
        (this.t_x = t), (this.t_y = e), this.pos(t, e);
      }),
      (i.prototype.resetPos = function () {
        this.pos(this.t_x, this.t_y);
      }),
      (i.prototype.isDie = function () {
        return "die" == this.heroName;
      }),
      (i.prototype.die = function () {
        "die" != this.heroName &&
          ((this.hp.visible = !1),
          (this.mp.visible = !1),
          (this.buff.visible = !1),
          (this.speedImg.visible = !1),
          (this.heartImg.visible = !1),
          (this.speedLabel.visible = !1),
          (this.typeImg.visible = !1),
          (this.heroName = "die"),
          this.shuang.stop(),
          (this.shuang.alpha = 0),
          this.body.pos(0, 0),
          i.isCache[this.heroName]
            ? this.payAction("idle")
            : ((this.atlas = i.path + "die.atlas"),
              Laya.loader.load(
                this.atlas,
                Laya.Handler.create(this, this.onLoadDie),
                null,
                Laya.Loader.ATLAS
              )));
      }),
      (i.prototype.resurgence = function () {
        "die" == this.heroName &&
          ((this.hp.visible = !0),
          (this.mp.visible = !0),
          (this.buff.visible = !0),
          (this.speedImg.visible = !0),
          (this.speedLabel.visible = !0),
          (this.typeImg.visible = !0),
          (this.heroName = this.oldName),
          this.posOffset(),
          i.isCache[this.heroName]
            ? this.payAction("idle")
            : ((this.atlas = i.path + "die.atlas"),
              Laya.loader.load(
                this.atlas,
                Laya.Handler.create(this, this.onLoadDie),
                null,
                Laya.Loader.ATLAS
              )));
      }),
      (i.prototype.onLoadDie = function (t) {
        Laya.Animation.createFrames(
          this.aniUrls("attack", 1),
          this.heroName + "_attack"
        ),
          Laya.Animation.createFrames(
            this.aniUrls("idle", 4),
            this.heroName + "_idle"
          ),
          this.payAction("idle"),
          (i.isCache[this.heroName] = !0);
      }),
      (i.prototype.mapSpeed = function (t) {
        return "一" == t
          ? "1"
          : "二" == t
          ? "2"
          : "三" == t
          ? "3"
          : "四" == t
          ? "4"
          : "五" == t
          ? "5"
          : "六" == t
          ? "6"
          : "七" == t
          ? "7"
          : "八" == t
          ? "8"
          : "九" == t
          ? "9"
          : t || "";
      }),
      (i.prototype.stopPlay = function () {
        (this.isInit = !1),
          (this.isLoad = !1),
          this.body.stop(),
          this.shuang.stop(),
          (this.shuang.alpha = 0),
          this.removeSelf(),
          this.buff.refresh(0);
      }),
      (i.prototype.startShuang = function () {
        t.Talent.load(this, "hong-3") &&
          ((this.shuang.alpha = 1), this.shuang.play(0, !0, "talenthong-3"));
      }),
      (i.prototype.stopShuang = function () {
        this.shuang.stop(), (this.shuang.alpha = 0);
      }),
      (i.prototype.posOffset = function () {
        var t = !1;
        Dictionary.posOffset.indexOf(this.heroName, 0) >= 0 && (t = !0);
        var e = 0;
        t && (e = -10), this.isNewImage && (e = -40);
        Dictionary.posOffset_20.indexOf(this.heroName, 0) >= 0 && (e = -25),
          this.body.pos(e, 0);
      }),
      (i.prototype.isNewImageSet = function () {
        return Dictionary.newImageSet.indexOf(this.heroName, 0) >= 0;
      }),
      (i.path = "res/atlas/fight/hero/"),
      (i.typeImgArray = [
        "",
        "comp/commonpic/wu.png",
        "comp/commonpic/wen.png",
        "comp/commonpic/yi.png",
      ]),
      (i.isCache = {}),
      i
    );
  })(Laya.Sprite);
  t.FightRole = e;
})(Fight || (Fight = {}));
